﻿using StoryTeller.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoryTeller.Infrastructure.DataAccess.Parser
{
    public static class GroupContributorRequestParser
    {
        public static ContributorRequest ParseEntityToDomain(this EGroupContributorRequest entity)
        {
            ContributorRequest creq = new ContributorRequest();

            creq.LastUpdate = entity.LastUpdate.Value;
            creq.CreationDate = entity.CreationDate;
            creq.Contributor = entity.User.ParseEntityToDomain();
            creq.Description = entity.Description;
            creq.ContributeIn = entity.Group.ParseEntityToDomain();

            return creq;
        }

        public static EGroupContributorRequest ParseDomainToEntity(this ContributorRequest domain)
        {
            EGroupContributorRequest creq = new EGroupContributorRequest();

            creq.CreationDate = domain.CreationDate;
            creq.LastUpdate = domain.LastUpdate;
            creq.User = domain.Contributor.ParseDomainToEntity();
            creq.Description = domain.Description;
            creq.Group = ((Group)domain.ContributeIn).ParseDomainToEntity();

            return creq;
        }
    }
}
